//
//  XFStatusForwardCell.swift
//  mxfweibo
//
//  Created by apple1 on 15/12/22.
//  Copyright © 2015年 莫祥富. All rights reserved.
//

import UIKit

class XFStatusForwardCell: XFStatusCell {
    
    override var status: XFStatus? {
        didSet {
            
            if let forwardStatus = status?.retweeted_status {
                
                let text = "@\(forwardStatus.user!.screen_name!): \(forwardStatus.text!)"
                forwardLabel.text = text
            }
            
        }
    }
 
    override func prepareUI() {
        super.prepareUI()
        

        contentView.addSubview(bgButton)
        contentView.addSubview(forwardLabel)
        
        contentView.sendSubviewToBack(bgButton)
        
        bgButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView:contentLabel , size: nil, offset: CGPoint(x: -8, y: 8))
        bgButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil, offset: CGPoint(x: 8, y: -8))
        
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: bgButton, size: nil, offset: CGPoint(x: 8, y: 8))
        
        contentView.addConstraint(NSLayoutConstraint(item: forwardLabel, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: UIScreen.mainScreen().bounds.width - 2*8))
        
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: 290, height: 290), offset: CGPoint(x: 0, y: 8))
        
        pictureViewWidthCon = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureViewHeightCon = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
    }
    

    
    //MARK: - 懒加载控件
    //背景按钮
    private lazy var bgButton: UIButton = {
        
        let button = UIButton()
        
        button.backgroundColor = UIColor(white: 0.88, alpha: 1)
        
        return button
    }()
    
    //被转发微博内容
    private lazy var forwardLabel: UILabel = {
        
        let label = UILabel(color: UIColor.darkGrayColor(), fontSize: 14)
        label.numberOfLines = 0
        return label
    }()
    

}
